﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCFServiceModel.Model;
using System.Runtime.Serialization;
using Microsoft.WindowsAzure.MobileServices;
using WCFServiceModel;

namespace WCFServiceModel.Model
{
    public class Session
    {

        private string _id;
        [DataMember]
        public string Id
        {
            get { return _id; }
            set { _id = value; }
        }

        private DateTime _startDate;
        [DataMember]
        public DateTime StartDate
        {
            get { return _startDate; }
            set { _startDate = value; }
        }
        private DateTime _endDate;
        [DataMember]
        public DateTime EndDate
        {
            get { return _endDate; }
            set { _endDate = value; }
        }
        private string _user;
        [DataMember]
        public string User
        {
            get { return _user; }
            set { _user = value; }
        }
        private string _application;
        [DataMember]
        public string Application
        {
            get { return _application; }
            set { _application = value; }
        }

        public Session()
        {
            Id = Guid.NewGuid().ToString();
            _startDate = DateTime.Now;

        }

        private IMobileServiceTable<Session> sesionTable = ServiceManager.getCurrentContext().GetTable<Session>();

        public Session(string user, string application)
        {
            _startDate = DateTime.Now;
            User = user;
            Application = application;
            InsertSesion();
        }
        //add business logic
        private async void InsertSesion()
        {
           //    await sesionTable.InsertAsync(this);
        }
    }
}
